package com.jiazhong.boot.mvc.controller;

import com.jiazhong.boot.commons.bean.Users;
import com.jiazhong.boot.commons.util.JsonResult;
import com.jiazhong.boot.commons.util.ResultTool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
// 当前类的所有请求，都允许其他项目方法
@CrossOrigin
@Slf4j
// @Controller+@ResponseBody
@RestController
@RequestMapping("/fifth")
public class FifthController {

    // @RequestMapping(value = "/a", method = RequestMethod.GET)
    // @GetMapping("/a")
    @GetMapping
    public JsonResult a() {
        log.info("用户访问了FifthController的a方法");
        return ResultTool.success("用户访问了FifthController的a方法");
    }

    @PostMapping
    public JsonResult b(String name, int age) {
        log.info("用户访问了FifthController的b方法");
        log.info("name:{},age:{}", name, age);
        return ResultTool.success("用户访问了FifthController的b方法");
    }

    @PostMapping("/c1")
    public JsonResult c1(Users user) {
        log.info("用户访问了FifthController的c1方法");
        log.info("user:{}", user);
        return ResultTool.success("用户访问了FifthController的c1方法");
    }

    @PostMapping("/c2")
    public JsonResult c2(@RequestBody Users user) {
        log.info("用户访问了FifthController的c2方法");
        log.info("user:{}", user);
        return ResultTool.success("用户访问了FifthController的c2方法");
    }

    @PutMapping("/d")
    public JsonResult d(Users user) {
        log.info("用户访问了FifthController的d方法");
        log.info("user:{}", user);
        return ResultTool.success("用户访问了FifthController的d方法");
    }
    @DeleteMapping("/e")
    public JsonResult e(Users user){
        log.info("用户访问了FifthController的e方法");
        log.info("user:{}", user);
        return ResultTool.success("用户访问了FifthController的e方法");
    }
}
